require("../less/myBadge.less");
document.ready(function() {

    axios.defaults.baseURL = "http://139.9.177.51:8099";

    //返回上一页
    document.querySelector('#backprev').addEventListener('click', function() {
        history.go(-1);
    })


    //获取我的运动勋章信息
    axios.get("/users/mysportsBadge?userId=" + localStorage.userId)
        .then(function(res) {
            if (res.data.status == 0) {
                console.log(res.data.data);
            }
        })
        .catch(function(err) {
            console.log(err);
        })

    //获取排名
    getRank();

    function getRank() {
        axios.get("/headPageInfo?userId=" + localStorage.userId)
            .then(function(res) {
                if (res.data.status === 0) {
                    document.querySelector('#rank').textContent = res.data.data.rank;
                }
            })
            .catch(function(err) {
                console.log(err);
            })
    }

    document.querySelector('#badges').addEventListener('click', function(e) {
        console.log(e.target);
        console.log(e.target.closest('li'));
        if (e.target.closest('li').nodeName === 'LI') {
            location.href = './showBadge.html';
        }
    })

})